﻿
namespace KinonekoSoftware.Foundation.Styles
{
    public sealed class CustomThemeSystem : ThemeSystem
    {


        public CustomThemeSystem(IEnumerable<string> resource)
        {
            var select = resource.Select(x =>
            {
                var contents = x.Split(',');
                var key      = contents.FirstOrDefault();
                var value    = contents.LastOrDefault();
                return new ValueTuple<string, string>(key, value);
            }).Where(x =>
            {
                var (key, value) = x; 
                return !string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value);
            }).Select(x =>
            {
                var (key, value) = x; 
                var brush = (BrushKey)(int.TryParse(key, out var n) ? n : 0);
                var color = (uint.TryParse(value, out var c) ? c : FromARGB(255, 0, 0, 0));
                return new KeyValuePair<BrushKey, uint>(brush, color);
            });
            
            Colors = new Dictionary<BrushKey, uint>(select);
        }


        protected override void InitializeOverlayBrush(Dictionary<BrushKey, uint> colors)
        {

        }

        protected override void InitializeBackgroundBrush(Dictionary<BrushKey, uint> colors)
        {
        }

        protected override void InitializeForegroundBrush(Dictionary<BrushKey, uint> colors)
        {
        }

        protected override void InitializeAdaptiveBrush(Dictionary<BrushKey, uint> colors)
        {
        }
    }
}